package com.example.a1.fannong.core.http.requester.user;

import com.example.a1.fannong.core.http.OnResultListener;
import com.example.a1.fannong.core.http.ServiceName;
import com.example.a1.fannong.core.http.SimpleHttpRequester;
import com.example.a1.fannong.core.manager.user.User;

import org.json.JSONObject;

import java.util.Map;

import cn.personal.library.json.JsonHelper;

/**
 * 登录接口
 */
public class LoginRequester extends SimpleHttpRequester<User> {
    public String phone;
    public String passWord;

    public LoginRequester(OnResultListener<User> onResultListener) {
        super(onResultListener);
    }

    @Override
    protected User onDumpData(JSONObject jsonData) {
        JSONObject data = jsonData.optJSONObject(KEY_WEB_DATA);
        User user = JsonHelper.toObject(data,User.class);
        return user;
    }

    @Override
    protected void onPutParams(Map<String, Object> params) {
        params.put("username", phone);
        params.put("password", passWord);
        params.put("appType", "2");
    }

    @Override
    protected ServiceName getServiceName() {
        return ServiceName.login;
    }

}
